@@ -2,6 +2,9 @@ source 'https://rubygems.org' |
||
| 2 | 2 |
|
| 3 | 3 |
ruby '2.0.0' |
| 4 | 4 |
|
| 5 |
+# Use Unicorn server |
|
| 6 |
+gem 'unicorn' |
|
| 7 |
+ |
|
| 5 | 8 |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' |
| 6 | 9 |
gem 'rails', '4.0.4' |
| 7 | 10 |
|
@@ -139,6 +139,7 @@ GEM |
||
| 139 | 139 |
railties (>= 3.0, < 5.0) |
| 140 | 140 |
thor (>= 0.14, < 2.0) |
| 141 | 141 |
json (1.8.1) |
| 142 |
+ kgio (2.9.2) |
|
| 142 | 143 |
launchy (2.4.2) |
| 143 | 144 |
addressable (~> 2.3) |
| 144 | 145 |
less (2.5.0) |
@@ -191,6 +192,7 @@ GEM |
||
| 191 | 192 |
activesupport (= 4.0.4) |
| 192 | 193 |
rake (>= 0.8.7) |
| 193 | 194 |
thor (>= 0.18.1, < 2.0) |
| 195 |
+ raindrops (0.13.0) |
|
| 194 | 196 |
rake (10.3.2) |
| 195 | 197 |
rdoc (4.1.2) |
| 196 | 198 |
json (~> 1.4) |
@@ -274,6 +276,10 @@ GEM |
||
| 274 | 276 |
uglifier (2.5.3) |
| 275 | 277 |
execjs (>= 0.3.0) |
| 276 | 278 |
json (>= 1.8.0) |
| 279 |
+ unicorn (4.8.3) |
|
| 280 |
+ kgio (~> 2.6) |
|
| 281 |
+ rack |
|
| 282 |
+ raindrops (~> 0.7) |
|
| 277 | 283 |
vegas (0.1.11) |
| 278 | 284 |
rack (>= 1.0.0) |
| 279 | 285 |
warden (1.2.3) |
@@ -328,3 +334,4 @@ DEPENDENCIES |
||
| 328 | 334 |
turbolinks |
| 329 | 335 |
twitter-bootstrap-rails |
| 330 | 336 |
uglifier (>= 1.3.0) |
| 337 |
+ unicorn |
@@ -1,2 +1 @@ |
||
| 1 |
-web: bundle exec rails server -p $PORT |
|
| 2 |
-worker: env QUEUE=* bundle exec rake resque:work |
|
| 1 |
+web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
@@ -0,0 +1,34 @@ |
||
| 1 |
+# config/unicorn.rb |
|
| 2 |
+ |
|
| 3 |
+# See comment by @paulelliott |
|
| 4 |
+worker_processes 3 |
|
| 5 |
+timeout 30 |
|
| 6 |
+preload_app true |
|
| 7 |
+ |
|
| 8 |
+before_fork do |server, worker| |
|
| 9 |
+ # Replace with MongoDB or whatever |
|
| 10 |
+ if defined?(ActiveRecord::Base) |
|
| 11 |
+ ActiveRecord::Base.connection.disconnect! |
|
| 12 |
+ Rails.logger.info('Disconnected from ActiveRecord')
|
|
| 13 |
+ end |
|
| 14 |
+ |
|
| 15 |
+ # If you are using Redis but not Resque, change this |
|
| 16 |
+ if defined?(Resque) |
|
| 17 |
+ Resque.redis.quit |
|
| 18 |
+ Rails.logger.info('Disconnected from Redis')
|
|
| 19 |
+ end |
|
| 20 |
+end |
|
| 21 |
+ |
|
| 22 |
+after_fork do |server, worker| |
|
| 23 |
+ # Replace with MongoDB or whatever |
|
| 24 |
+ if defined?(ActiveRecord::Base) |
|
| 25 |
+ ActiveRecord::Base.establish_connection |
|
| 26 |
+ Rails.logger.info('Connected to ActiveRecord')
|
|
| 27 |
+ end |
|
| 28 |
+ |
|
| 29 |
+ # If you are using Redis but not Resque, change this |
|
| 30 |
+ if defined?(Resque) |
|
| 31 |
+ Resque.redis = ENV['REDIS_URI'] |
|
| 32 |
+ Rails.logger.info('Connected to Redis')
|
|
| 33 |
+ end |
|
| 34 |
+end |